#  -*- coding: utf-8 -*-
from util.g import g
from util.selenium.webdriver.common.by import By

from base.BaseMethod import BM
from util.DataQuery.FormDataDecorator import FormDataDecorator

from PageObject.IAMgtTech import IAMgtTech
from PageObject.IARdmDesc import IARdmDesc
from PageObject.IARiprIec import IARiprIec
from PageObject.IAStaDesc import IAStaDesc


class WriteInnovationAbilityForm():
    form_btn_loc = (By.LINK_TEXT, '企业创新能力')
    content_iframe_loc = (By.CSS_SELECTOR, "#innocomFrame")

    # 写代码时方便提示, 基本方法完成后删除
    # driver = driver
    def __init__(self, driver=None):
        self.driver = driver
    @property
    def class_name(self):
        return self.__class__.__name__

    @FormDataDecorator
    def main(self, ripr_iec='', sta_desc='', rdm_desc='', mgt_tech=''):
        # 点击 企业创新能力 表单按钮。
        BM.click(driver=self.driver, ele_loc=self.form_btn_loc)
        BM.cut_over_frame(driver=self.driver, selector_loc=self.content_iframe_loc)
        #  实例化 ia_* 四个类对象，然后分别执行 fill_form 方法
        IARiprIec(driver=self.driver, text=ripr_iec).fill_form()
        sta_info = IAStaDesc(driver=self.driver, text=sta_desc)
        sta_info.fill_form()
        if g.record.sta_status != 1:
            sta_info.ia_sta_desc()
        ia_rdm_desc = IARdmDesc(driver=self.driver, text=rdm_desc)
        ia_rdm_desc.fill_form()
        ia_rdm_desc.upload_file()
        IAMgtTech(driver=self.driver, text=mgt_tech).fill_form()

if __name__ == '__main__':
    a = WriteInnovationAbilityForm(driver='fdsji')
    print(a.write_innovation_ability_form.__code__.co_varnames)
